///
/// Override this method to filter the ${Second Filter Control}DropDownList
/// based on the value selected for the ${First Filter Control}DropDownList
///
protected void Populate${Second Filter Control}DropDown(int maxItems)
{
// Set up the WHERE clause.
// Create the WHERE clause to filter the second filter based on the
// selected value in the first filter.
WhereClause wc = new WhereClause();
string selectedValue = ${First Filter Control}.SelectedValue;
string selectedText = ${First Filter Control}.SelectedItem.Text;
wc.iAND(${${Table}ClassName}.${First Filter Field}, BaseFilter.ComparisonOperator.EqualsTo, selectedValue);
// Clear the contents of second filter.
this.${Second Filter Control}.Items.Clear();
// Add "Please Select" string to second filter.
this.${Second Filter Control}.Items.Insert(0, new ListItem(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"), "--PLEASE_SELECT--"));
if(BaseClasses.Utils.StringUtils.InvariantUCase(selectedText).Equals(BaseClasses.Utils.StringUtils.InvariantUCase(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"))))
{
// if "Please Select" string is selected for first filter,
// then do not continue populating the second filter.
return;
}
// Get the records using the created where clause.
foreach ( ${${Table}RecordClassName} itemValue in ${${Table}ClassName}.GetRecords(wc, null, 0, maxItems))
{
if(itemValue.${Second Filter Field}Specified)
{
// In each record, obtain the value of Second Filter Field if value exists,
// create an item for it and add it to the list.
string cvalue = itemValue.${Second Filter Field}.ToString();
string fvalue = itemValue.Format(${${Table}ClassName}.${Second Filter Field});
ListItem item = new ListItem(fvalue, cvalue);
if (! this.${Second Filter Control}.Items.Contains(item))
{
this.${Second Filter Control}.Items.Add(item);
}
}
}
// Select "Please Select" string in the second filter.
this.${Second Filter Control}.SelectedIndex = 0;
}
|